package com.project.weimi.adapter;

import java.util.List;

import com.project.weimi.R;
import com.project.weimi.entity.response.IntegralDailyTaskEntity;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class IntegralDailyTaskAdapter extends BaseAdapter{

	private Context context;
	private List<IntegralDailyTaskEntity> dailyList;
	
	public IntegralDailyTaskAdapter(Context context, List<IntegralDailyTaskEntity> dailyList) {
		super();
		this.context = context;
		this.dailyList = dailyList;
	}

	// 设置ListView的item无法点击 
	@Override
	public boolean isEnabled(int position) {
		return false;
	}
	
	@Override
	public int getCount() {
		return dailyList.size();
	}

	@Override
	public Object getItem(int position) {
		return null;
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder vh = null;
		if(convertView == null){
			vh = new ViewHolder();
			// 解析布局文件
			convertView = LayoutInflater.from(context).inflate(R.layout.integral_dailytask_listview_item, null);
			// 获得控件对象
			vh.view_integralShop = (View)convertView.findViewById(R.id.view_integralShop);
			vh.tv_title = (TextView)convertView.findViewById(R.id.tv_title);
			vh.tv_integral = (TextView)convertView.findViewById(R.id.tv_integral);
			vh.tv_classes = (TextView)convertView.findViewById(R.id.tv_classes);
			vh.tv_num = (TextView)convertView.findViewById(R.id.tv_num);
			convertView.setTag(vh);
		}else{
			vh = (ViewHolder) convertView.getTag();
		}
				
		vh.tv_title.setText(dailyList.get(position).getTitle());
		vh.tv_integral.setText(dailyList.get(position).getIntegral());
		vh.tv_classes.setText(dailyList.get(position).getClasses());
		vh.tv_num.setText(dailyList.get(position).getNum());
		
		return convertView;
	}

	class ViewHolder{
		View view_integralShop;
		TextView tv_title;
		TextView tv_integral;
		TextView tv_classes;
		TextView tv_num;
	}
	
	
}
